package com.huaxia.day11;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ArrayTestN {
    public static void main(String[] args) {

    }

    /**
     * 理解数组
     */
    public static void create() {
        String[] arr1 = new String[2];
        arr1[0] = "hello";
        arr1[1] = "world";
        arr1[2] = "java";
        String[] arr2 = {"数组0", "数组1", "数组2", "...."};
        String[] arr3 = new String[]{"数组0", "数组1", "数组2", "...."};
        System.out.println(arr3.length);

    }

    /**
     * 理解二维数组
     */
    public static void create2Arr() {
        float[][] numthree;             //定义一个float类型的2维数组
        numthree = new float[5][5];       //为它分配5行5列的空间大小
        numthree[0][0] = 1.1f;            //通过下标索引去访问     1行1列=1.1
        numthree[1][0] = 1.2f;                                  // 2行1列=1.2
        numthree[2][0] = 1.3f;                                  // 3行1列=1.3
        numthree[3][0] = 1.4f;                                  // 4行1列=1.4
        numthree[4][0] = 1.5f;                                  // 5行1列=1.


        short[][] numfour = new short[5][8]; //定义一个short类型的数组同时为它分配5行8列的空间大小
        numfour[0][7] = 10;
        numfour[1][6] = 20;

        long[][] numfive = new long[5][];     //定义一个long类型的不规则数组
        numfive[0] = new long[5];             //为第1行分配5列
        numfive[1] = new long[6];             //为第2行分配6列
        numfive[2] = new long[7];             //为第3行分配7列

        double[][] numsix = {{1.111D, 2.222D, 3.333D}, {4.444D, 5.555D, 6.666D}};//定义double型的数组分配3行3列的空间同时赋值
        System.out.println(numsix[0][0]); //打印换行输出1行1列=1.111
        System.out.println(numsix[1][1]); //打印换行输出2行2列=5.555


        int[] a[] = new int[10][10];
    }


    /**
     * 数组排序 求最小值
     */

    public static void arraySort() {
        int[] x = {14, 15, 45, 978, 1587};
        int min = x[0];
        for (int i = 1; i < x.length; i++) {
            if (x[i] < min) {
                min = x[i];
            }
        }
        System.out.println("最小值："+min);

    }

    /**
     * 数组排序 求最小值
     */

    public static void arraySort(int[] x) {
        int min = x[0];
        for (int i = 1; i < x.length; i++) {
            if (x[i] < min) {
                min = x[i];
            }
        }
        System.out.println("最小值："+min);

    }

    public static void t2() throws IOException {
        BufferedReader buf=new BufferedReader(
                new InputStreamReader(System.in));
        while(true) {
            String str = buf.readLine();
            if(str.equals("quit"))
                break;
            int x=Integer.parseInt(str);
            System.out.println(x+x);
        }

    }
}
